package araujoCoronelVillamayor.plantasVsZombies.uiWicket;

import araujoCoronelVillamayor.plantasVsZombies.appModelsArena.JardinZenAppModel;
import araujoCoronelVillamayor.plantasVsZombies.uiWicket.JardinPage;
import araujoCoronelVillamayor.plantasVsZombies.uiWicket.layouts.LayoutPrincipal;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.model.CompoundPropertyModel;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function0;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure0;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.uqbar.wicket.xtend.WicketExtensionFactoryMethods;
import org.uqbar.wicket.xtend.XLink;
import org.uqbar.wicket.xtend.XListView;

@SuppressWarnings("all")
public class JardinZenPage extends LayoutPrincipal {
  @Extension
  private WicketExtensionFactoryMethods _wicketExtensionFactoryMethods = new Function0<WicketExtensionFactoryMethods>() {
    public WicketExtensionFactoryMethods apply() {
      WicketExtensionFactoryMethods _wicketExtensionFactoryMethods = new WicketExtensionFactoryMethods();
      return _wicketExtensionFactoryMethods;
    }
  }.apply();
  
  private final JardinPage mainPage;
  
  public JardinZenPage(final JardinZenAppModel JardinZenAppModelParametro, final JardinPage mainPage) {
    super();
    this.mainPage = mainPage;
    CompoundPropertyModel<JardinZenAppModel> _compoundPropertyModel = new CompoundPropertyModel<JardinZenAppModel>(JardinZenAppModelParametro);
    this.setDefaultModel(_compoundPropertyModel);
    this.mostrarJardinZen("Terrestre");
    Label _label = new Label("cantidadPlantasTerrestres");
    this._wicketExtensionFactoryMethods.addChild(this, _label);
    Label _label_1 = new Label("cantidadPlantasAcuaticas");
    this._wicketExtensionFactoryMethods.addChild(this, _label_1);
    XLink<Object> _xLink = new XLink<Object>("botonJardinTerrestre");
    final Procedure1<XLink<Object>> _function = new Procedure1<XLink<Object>>() {
      public void apply(final XLink<Object> it) {
        final Procedure0 _function = new Procedure0() {
          public void apply() {
            JardinZenPage.this.mostrarJardinZen("Terrestre");
          }
        };
        it.setOnClick(_function);
      }
    };
    XLink<Object> _doubleArrow = ObjectExtensions.<XLink<Object>>operator_doubleArrow(_xLink, _function);
    this._wicketExtensionFactoryMethods.addChild(this, _doubleArrow);
    XLink<Object> _xLink_1 = new XLink<Object>("botonJardinAcuatico");
    final Procedure1<XLink<Object>> _function_1 = new Procedure1<XLink<Object>>() {
      public void apply(final XLink<Object> it) {
        final Procedure0 _function = new Procedure0() {
          public void apply() {
            JardinZenPage.this.mostrarJardinZen("Acuatica");
          }
        };
        it.setOnClick(_function);
      }
    };
    XLink<Object> _doubleArrow_1 = ObjectExtensions.<XLink<Object>>operator_doubleArrow(_xLink_1, _function_1);
    this._wicketExtensionFactoryMethods.addChild(this, _doubleArrow_1);
    XLink<Object> _xLink_2 = new XLink<Object>("volverJardin");
    final Procedure1<XLink<Object>> _function_2 = new Procedure1<XLink<Object>>() {
      public void apply(final XLink<Object> it) {
        final Procedure0 _function = new Procedure0() {
          public void apply() {
            JardinZenPage.this.volver();
          }
        };
        it.setOnClick(_function);
      }
    };
    XLink<Object> _doubleArrow_2 = ObjectExtensions.<XLink<Object>>operator_doubleArrow(_xLink_2, _function_2);
    this._wicketExtensionFactoryMethods.addChild(this, _doubleArrow_2);
    XListView<Object> _xListView = new XListView<Object>("resultadosJardinZen");
    final XListView<Object> listViewZen = _xListView;
    final Procedure1<ListItem<Object>> _function_3 = new Procedure1<ListItem<Object>>() {
      public void apply(final ListItem<Object> item) {
        Object _modelObject = item.getModelObject();
        CompoundPropertyModel<Object> _asCompoundModel = JardinZenPage.this._wicketExtensionFactoryMethods.<Object>asCompoundModel(_modelObject);
        item.setModel(_asCompoundModel);
        Label _label = new Label("nombre");
        JardinZenPage.this._wicketExtensionFactoryMethods.addChild(item, _label);
        Label _label_1 = new Label("ataque");
        JardinZenPage.this._wicketExtensionFactoryMethods.addChild(item, _label_1);
        Label _label_2 = new Label("defensa");
        JardinZenPage.this._wicketExtensionFactoryMethods.addChild(item, _label_2);
      }
    };
    listViewZen.setPopulateItem(_function_3);
    this._wicketExtensionFactoryMethods.addChild(this, listViewZen);
  }
  
  public void volver() {
    this.setResponsePage(this.mainPage);
  }
  
  public void mostrarJardinZen(final String tipoTerrenoParam) {
    JardinZenAppModel _jardinZenAppModel = this.getJardinZenAppModel();
    _jardinZenAppModel.refreshJardinZen(tipoTerrenoParam);
  }
  
  public JardinZenAppModel getJardinZenAppModel() {
    Object _defaultModelObject = this.getDefaultModelObject();
    return ((JardinZenAppModel) _defaultModelObject);
  }
}
